package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.dto.ServiceProjectDto;
import com.zzyl.nursing.mapper.NursingProjectMapper;
import com.zzyl.nursing.mapper.ServiceProjectMapper;
import com.zzyl.nursing.service.ServiceProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.zzyl.common.utils.PageUtils.startPage;

@Service
public class ServiceProjectServiceImpl extends ServiceImpl<NursingProjectMapper, NursingProject> implements ServiceProjectService {

    @Autowired
    ServiceProjectMapper serviceProjectMapper;

    @Override
    public TableDataInfo<NursingProject> getProjectList(Integer pageNum, Integer pageSize, String name, Integer status) {
        startPage();
        List<NursingProject> list = serviceProjectMapper.getProjectList(name, status);
        Long l = serviceProjectMapper.selectCount(null);
        TableDataInfo<NursingProject> serviceProjectDto = new TableDataInfo<>();
        serviceProjectDto.setRows(list);
        serviceProjectDto.setTotal(Math.toIntExact(l));
        return serviceProjectDto;
    }
}
